package com.jsmtr.rms.controller;

import com.jsmtr.rms.entity.*;
import com.jsmtr.rms.service.*;
import com.jsmtr.rms.utils.EnumTools;
import com.jsmtr.rms.utils.StringTools;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.CellType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;

/**
 * Excel下载控制器
 * @author: cyx
 * @description:
 * @date: Created in 2018/7/9 14:06
 * @modified by:
 */
@RequestMapping("/ExcelDown")
@Controller
public class ExcelDownController {

    @Resource
    private IUtilService utilService;

    @Resource
    private IDoBSService bsService;
    @Resource
    private IProjectService projectService;

    @Resource
    private IExcelExportService excelExportService;
    //[start] 导出准考证

    /**
     * 返回Excel配置页面
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/DownDoResume")
    public  String downDoResume(HttpServletRequest request, HttpServletResponse response, Model model){
        /*String pid=request.getParameter("pid");
        String fid=request.getParameter("fid");
        String deptcode=request.getParameter("deptcode");
        model.addAttribute("pid",pid);
        model.addAttribute("fid",fid);
        model.addAttribute("deptcode",deptcode);*/
        Map parameterMap=request.getParameterMap();
        StringBuffer searchedata=new StringBuffer();
        String fid=request.getParameter("fid");
        ProjectInfoFlow projectInfoFlow;
        try {
           projectInfoFlow= projectService.getFolwById(fid);
           if(projectInfoFlow!=null){
               model.addAttribute("nowflow",projectInfoFlow.getNickname());
           }

        }catch (Exception e){
            e.printStackTrace();
        }


        for (Object pkey : parameterMap.keySet()) {
            String value=((String[])parameterMap.get(pkey))[0];
            try {
                if(value!=null&&!value.equalsIgnoreCase("")){
                searchedata.append("<input type=\"hidden\" name=\""+pkey.toString()+"\" value=\""+ URLDecoder.decode(value,"UTF-8")+"\" />");
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        model.addAttribute("searchdata",searchedata.toString());

        return "/ExcelDown/DownDoResume";
    }

    @RequestMapping("/DownDNZResume")
    public  String downDNZResume(HttpServletRequest request, HttpServletResponse response, Model model){
        Map parameterMap=request.getParameterMap();
        StringBuffer searchedata=new StringBuffer();
        String fid=request.getParameter("fid");
        ProjectInfoFlow projectInfoFlow;
        try {
            projectInfoFlow= projectService.getFolwById(fid);
            if(projectInfoFlow!=null){
                model.addAttribute("nowflow",projectInfoFlow.getNickname());
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        for (Object pkey : parameterMap.keySet()) {
            String value=((String[])parameterMap.get(pkey))[0];
            try {
                if(value!=null&&!value.equalsIgnoreCase("")){
                    searchedata.append("<input type=\"hidden\" name=\""+pkey.toString()+"\" value=\""+ URLDecoder.decode(value,"UTF-8")+"\" />");
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        model.addAttribute("searchdata",searchedata.toString());

        return "/ExcelDown/DownDNZResume";
    }

    /**
     * 导出简历
     * @param request
     * @param response
     */
    @RequestMapping("/DownDoResumeByTemplate")
    public void DownDoResumeByTemplate(HttpServletRequest request, HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        String codedFileName = null;
        OutputStream fOut = null;


            try {
                String sid=request.getParameter("ids");
                String[] ids=null;
                if(StringTools.trimNotEmpty(sid)) {
                    ids = sid.split(",");
                }
                String pid=request.getParameter("pid");
                String userids="";
                ProjectInfo projectInfo=projectService.getpProjectById(pid);
                
                codedFileName = java.net.URLEncoder.encode(projectInfo.getPname(), "UTF-8");
                response.setHeader("content-disposition", "attachment;filename=" + codedFileName + ".xls");
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.createSheet("铁路集团应聘人员信息");
                HSSFRow headrow = sheet.createRow(0);//创建一行
                headrow.createCell(0).setCellValue(new HSSFRichTextString("序号"));
                headrow.createCell(1).setCellValue(new HSSFRichTextString("应聘岗位"));
                headrow.createCell(2).setCellValue(new HSSFRichTextString("姓名"));
                headrow.createCell(3).setCellValue(new HSSFRichTextString("性别"));
                headrow.createCell(4).setCellValue(new HSSFRichTextString("年龄"));
                headrow.createCell(5).setCellValue(new HSSFRichTextString("籍贯"));
                headrow.createCell(6).setCellValue(new HSSFRichTextString("身份证号"));
                headrow.createCell(7).setCellValue(new HSSFRichTextString("政治面貌"));
                headrow.createCell(8).setCellValue(new HSSFRichTextString("工龄"));
                headrow.createCell(9).setCellValue(new HSSFRichTextString("毕业院校"));
                headrow.createCell(10).setCellValue(new HSSFRichTextString("专业"));
                headrow.createCell(11).setCellValue(new HSSFRichTextString("最高学历"));
                headrow.createCell(12).setCellValue(new HSSFRichTextString("最高学历取得时间"));
                headrow.createCell(13).setCellValue(new HSSFRichTextString("最高学位"));
                headrow.createCell(14).setCellValue(new HSSFRichTextString("最高学位取得时间"));
                headrow.createCell(15).setCellValue(new HSSFRichTextString("最近一家工作时间"));
                headrow.createCell(16).setCellValue(new HSSFRichTextString("最近一家工作单位"));
                headrow.createCell(17).setCellValue(new HSSFRichTextString("最近一份工作岗位"));
                headrow.createCell(18).setCellValue(new HSSFRichTextString("获得职称"));
                headrow.createCell(19).setCellValue(new HSSFRichTextString("期望薪酬"));
                headrow.createCell(20).setCellValue(new HSSFRichTextString("联系电话"));
                List<Object[]> userResumeList;
                if (ids!=null&&ids.length>0){
                    for (String id : ids) {
                        userids+="'"+id+"',";
                    }
                    userids=userids.substring(0,userids.length()-1);
                }

                //改用大视图取消流程判断
                userResumeList=excelExportService.queryUserResumeByTemplate(pid,userids);
                if(userResumeList.size()>0){
                    int flag=1;
                    fOut= response.getOutputStream();
                    for (Object[] obj : userResumeList) {
                        HSSFRow row = sheet.createRow(flag);//创建一行
                        for (int j = 0; j < obj.length; j++) {
                            HSSFCell cell = row.createCell(j);//创建一列
                            cell.setCellType(CellType.STRING);
                            cell.setCellValue(new HSSFRichTextString(
                                    obj[j] == null ? "" : obj[j].toString()));
                        }
                        flag++;
                    }
                }
                fOut = response.getOutputStream();
                workbook.write(fOut);
            }catch (Exception e){
                e.printStackTrace();
            }finally {
                try {
                    fOut.flush();
                    fOut.close();
                } catch (IOException e) {
                }
            }
    }

    //[end]

    @RequestMapping("/DownDoResumeBySearch")
    public  String downDoResumeBySearch(HttpServletRequest request, HttpServletResponse response, Model model){
        //String pid=request.getParameter("pid");
        //String fid=request.getParameter("fid");
        //String deptcode=request.getParameter("deptcode");
       // String searchdata=request.getParameter("searchdata");
        //model.addAttribute("pid",pid);
        //model.addAttribute("fid",fid);
        //model.addAttribute("deptcode",deptcode);
        Map parameterMap=request.getParameterMap();
        StringBuffer searchedata=new StringBuffer();

        String fid=request.getParameter("fid");
        ProjectInfoFlow projectInfoFlow;
        try {
            projectInfoFlow= projectService.getFolwById(fid);
            if(projectInfoFlow!=null){
                model.addAttribute("nowflow",projectInfoFlow.getNickname());
            }

        }catch (Exception e){
            e.printStackTrace();
        }

        for (Object pkey : parameterMap.keySet()) {
            String value=((String[])parameterMap.get(pkey))[0];
                try {
                    searchedata.append("<input type=\"hidden\" name=\""+pkey.toString()+"\" value=\""+ URLDecoder.decode(value,"UTF-8")+"\"/>");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
        }

        model.addAttribute("searchdata",searchedata.toString());
        return "/ExcelDown/DownDoResumeBySearch";
    }


    /**
     * 导出简历
     * @param request
     * @param response
     */
    @RequestMapping("/ExportResumes")
    public void exportResumes(HttpServletRequest request, HttpServletResponse response,DUserResume users) {
        response.setContentType("application/vnd.ms-excel");
        String codedFileName = null;
        OutputStream fOut = null;
        Map<String,String[]> paramMap=request.getParameterMap();
        Map<String, Object> _map = new HashMap<String, Object>();
        _map.put("agefrom", request.getParameter("agefrom")==null?"":request.getParameter("agefrom").trim());
        _map.put("ageto", request.getParameter("ageto")==null?"":request.getParameter("ageto").trim());
        _map.put("heightfrom", request.getParameter("heightfrom")==null?"":request.getParameter("heightfrom").trim());
        _map.put("heightto", request.getParameter("heightto")==null?"":request.getParameter("heightto").trim());
        _map.put("graduationyear",request.getParameter("graduationyear")==null?"":request.getParameter("graduationyear").trim());
        _map.put("msplan", request.getParameter("msplan"));
        _map.put("msplantime", request.getParameter("msplantime"));
        _map.put("msaddress", request.getParameter("msaddress"));
        _map.put("usercontent", request.getParameter("usercontent"));
        _map.put("ischangejob",request.getParameter("ischangejob"));
        _map.put("msresult",request.getParameter("msresult"));
        _map.put("scorearea", request.getParameter("scorearea"));
        _map.put("wkcompanyname", request.getParameter("wkcompanyname"));
        _map.put("wkdepartment", request.getParameter("wkdepartment"));
        _map.put("wkposition", request.getParameter("wkposition"));
        _map.put("jobdepart", request.getParameter("jobdepart"));
        _map.put("adddate", request.getParameter("adddate"));
        _map.put("adddatefrom", request.getParameter("adddatefrom"));
        _map.put("adddateto", request.getParameter("adddateto"));
        if (StringTools.trimNotEmpty(users.getJname())){
            _map.put("jobname",request.getParameter("jname")==null?"":request.getParameter("jname"));
            users.setJname(null);
        }
        _map.put("ids", request.getParameter("checkIds")==null?"":request.getParameter("checkIds").trim());
        users.setPid("");
        if(paramMap.size()>0){
            try {
                String pid=request.getParameter("pid");
                String fid=request.getParameter("fid");
                ProjectInfo projectInfo=projectService.getpProjectById(pid);
                ProjectInfoFlow projectInfoFlow=projectService.getFolwById(fid);
                if(StringTools.trimNotEmpty(fid)){
                    users.setFid(null);
                }
                codedFileName = java.net.URLEncoder.encode(projectInfo.getPname(), "UTF-8");
                response.setHeader("content-disposition", "attachment;filename=" + codedFileName + ".xls");
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.createSheet("人员信息");

                int index=0;
                String selectColumns="";
                HSSFRow headrow = sheet.createRow(0);//创建一行
                for (String pkey : paramMap.keySet()) {
                    if (pkey.startsWith("KEY.")) {
                        HSSFCell headcel0 = headrow.createCell(index);
                        headcel0.setCellValue(new HSSFRichTextString(paramMap.get(pkey)[0]));
                        selectColumns += pkey.replace("KEY.","") + ",";
                        index++;
                    }
                }
                if(selectColumns.indexOf("p.ROWNUM")>0) {
                    selectColumns = selectColumns.replace("p.ROWNUM", "ROWNUM");
                }
                selectColumns=selectColumns.substring(0,selectColumns.length()-1);
                List<Object[]> userResumeList;
                String flowName=projectInfoFlow.getFname()==null?projectInfoFlow.getNickname():projectInfoFlow.getFname();

               //改用大视图取消流程判断
                userResumeList=excelExportService.queryUserResumeBySearch(pid,selectColumns,_map,users);
                if(userResumeList.size()>0){
                    int flag=1;
                    for (Object[] obj : userResumeList) {
                        HSSFRow row = sheet.createRow(flag);//创建一行
                        for (int j = 0; j < obj.length; j++) {
                            HSSFCell cell = row.createCell(j);//创建一列
                            cell.setCellType(CellType.STRING);
                            cell.setCellValue(new HSSFRichTextString(
                                    obj[j] == null ? "" : obj[j].toString()));
                        }
                        flag++;
                    }
                }
                fOut = response.getOutputStream();
                workbook.write(fOut);

            }catch (Exception e){
                e.printStackTrace();
            }finally {
                try {
                    fOut.flush();
                    fOut.close();
                } catch (IOException e) {
                }
            }
        }

        /*try {
            codedFileName = java.net.URLEncoder.encode("笔试准考证", "UTF-8");
            response.setHeader("content-disposition", "attachment;filename=" + codedFileName + ".xls");
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = workbook.createSheet();

            //[start] 表头

            HSSFRow headrow = sheet.createRow(0);//创建一行
            HSSFCell headcel0 = headrow.createCell(0);
            headcel0.setCellValue(new HSSFRichTextString("姓名"));
            HSSFCell headcel1 = headrow.createCell(1);
            headcel1.setCellValue(new HSSFRichTextString("证件号码"));
            HSSFCell headcel2 = headrow.createCell(2);
            headcel2.setCellValue(new HSSFRichTextString("性别"));
            HSSFCell headcel3 = headrow.createCell(3);
            headcel3.setCellValue(new HSSFRichTextString("手机"));
            HSSFCell headcel4 = headrow.createCell(4);
            headcel4.setCellValue(new HSSFRichTextString("应聘职位"));
            HSSFCell headcel5 = headrow.createCell(5);
            headcel5.setCellValue(new HSSFRichTextString("笔试场地"));
            HSSFCell headcel6 = headrow.createCell(6);
            headcel6.setCellValue(new HSSFRichTextString("准考证号"));
            HSSFCell headcel7 = headrow.createCell(7);
            headcel7.setCellValue(new HSSFRichTextString("座位号"));

            //[end]

            String[] _uids = request.getParameterValues("uid");
            String pid = request.getParameter("pid").trim();
            List<String> us = new ArrayList<String>();


            if (us.size() > 0) {
                String[] uids = (String[]) us.toArray(new String[us.size()]);

                String fid = request.getParameter("fid").trim();
                ProjectInfo project = projectService.getProjectInfo(fid);

                List<Object[]> objs = bsService.getBsTicket(fid, uids, project.getRecruittype());
                int i = 1;
                for (Object[] obj : objs) {
                    HSSFRow row = sheet.createRow(i);//创建一行
                    for (int j = 0; j < 8; j++) {
                        HSSFCell cell = row.createCell(j);//创建一列
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                        cell.setCellValue(new HSSFRichTextString(
                                obj[j] == null ? "" : obj[j].toString()));
                    }
                    i++;
                }
            }
            fOut = response.getOutputStream();
            workbook.write(fOut);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                fOut.flush();
                fOut.close();
            } catch (IOException e) {
            }
        }*/
    }

    //[end]


    /**
     * 导出简历
     * @param request
     * @param response
     */
    @RequestMapping("/ExportDNZResumes")
    public void exportDNZResumes(HttpServletRequest request, HttpServletResponse response,DNZResume dnzResume) {
        response.setContentType("application/vnd.ms-excel");
        String codedFileName = null;
        OutputStream fOut = null;
        Map<String,String[]> paramMap=request.getParameterMap();
        Map<String, Object> _map = new HashMap<String, Object>();
        _map.put("agefrom", request.getParameter("agefrom")==null?"":request.getParameter("agefrom").trim());
        _map.put("ageto", request.getParameter("ageto")==null?"":request.getParameter("ageto").trim());
        _map.put("heightfrom", request.getParameter("heightfrom")==null?"":request.getParameter("heightfrom").trim());
        _map.put("heightto", request.getParameter("heightto")==null?"":request.getParameter("heightto").trim());
        _map.put("graduationyear",request.getParameter("graduationyear")==null?"":request.getParameter("graduationyear").trim());
        _map.put("msplan", request.getParameter("msplan"));
        _map.put("msplantime", request.getParameter("msplantime"));
        _map.put("msaddress", request.getParameter("msaddress"));
        _map.put("usercontent", request.getParameter("usercontent"));
        _map.put("ischangejob",request.getParameter("ischangejob"));
        _map.put("msresult",request.getParameter("msresult"));
        _map.put("scorearea", request.getParameter("scorearea"));
        _map.put("wkcompanyname", request.getParameter("wkcompanyname"));
        _map.put("wkdepartment", request.getParameter("wkdepartment"));
        _map.put("wkposition", request.getParameter("wkposition"));
        _map.put("jobdepart", request.getParameter("jobdepart"));
        _map.put("adddate", request.getParameter("adddate"));
        _map.put("adddatefrom", request.getParameter("adddatefrom"));
        _map.put("adddateto", request.getParameter("adddateto"));
        if (StringTools.trimNotEmpty(dnzResume.getJname())){
            _map.put("jobname",request.getParameter("jname")==null?"":request.getParameter("jname"));
            dnzResume.setJname(null);
        }
        _map.put("ids", request.getParameter("checkIds")==null?"":request.getParameter("checkIds").trim());
        dnzResume.setPid("");
        if(paramMap.size()>0){
            try {
                String pid=request.getParameter("pid");
                String fid=request.getParameter("fid");
                ProjectInfo projectInfo=projectService.getpProjectById(pid);
                ProjectInfoFlow projectInfoFlow=projectService.getFolwById(fid);
                if(StringTools.trimNotEmpty(fid)){
                    dnzResume.setFid(null);
                }
                codedFileName = java.net.URLEncoder.encode(projectInfo.getPname(), "UTF-8");
                response.setHeader("content-disposition", "attachment;filename=" + codedFileName + ".xls");
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.createSheet("人员信息");

                int index=0;
                String selectColumns="";
                HSSFRow headrow = sheet.createRow(0);//创建一行
                for (String pkey : paramMap.keySet()) {
                    if (pkey.startsWith("KEY.")) {
                        HSSFCell headcel0 = headrow.createCell(index);
                        headcel0.setCellValue(new HSSFRichTextString(paramMap.get(pkey)[0]));
                        selectColumns += pkey.replace("KEY.","") + ",";
                        index++;
                    }
                }
                if(selectColumns.indexOf("p.ROWNUM")>0) {
                    selectColumns = selectColumns.replace("p.ROWNUM", "ROWNUM");
                }
                selectColumns=selectColumns.substring(0,selectColumns.length()-1);
                List<Object[]> userResumeList;
                String flowName=projectInfoFlow.getFname()==null?projectInfoFlow.getNickname():projectInfoFlow.getFname();

                //改用大视图取消流程判断
                userResumeList=excelExportService.queryDNZResumeBySearch(pid,selectColumns,_map,dnzResume);
                if(userResumeList.size()>0){
                    int flag=1;
                    for (Object[] obj : userResumeList) {
                        HSSFRow row = sheet.createRow(flag);//创建一行
                        for (int j = 0; j < obj.length; j++) {
                            HSSFCell cell = row.createCell(j);//创建一列
                            cell.setCellType(CellType.STRING);
                            cell.setCellValue(new HSSFRichTextString(
                                    obj[j] == null ? "" : obj[j].toString()));
                        }
                        flag++;
                    }
                }
                fOut = response.getOutputStream();
                workbook.write(fOut);

            }catch (Exception e){
                e.printStackTrace();
            }finally {
                try {
                    fOut.flush();
                    fOut.close();
                } catch (IOException e) {
                }
            }
        }
    }

    //[end]
    /**
     * 导出简历
     * @param request
     * @param response
     */
    @RequestMapping("/ExportResumesSearch")
    public void exportResumesSearch(HttpServletRequest request, HttpServletResponse response, HRZZUser hrzzUser) {
        response.setContentType("application/vnd.ms-excel");
        String codedFileName = null;
        OutputStream fOut = null;
        /* Enumeration<String> pnames= request.getParameterNames();*/
        Map<String,String[]> paramMap=request.getParameterMap();
        Map<String, Object> _map = new HashMap<String, Object>();
        _map.put("agefrom", request.getParameter("agefrom")==null?"":request.getParameter("agefrom").trim());
        _map.put("ageto", request.getParameter("ageto")==null?"":request.getParameter("ageto").trim());
        _map.put("heightfrom", request.getParameter("heightfrom")==null?"":request.getParameter("heightfrom").trim());
        _map.put("heightto", request.getParameter("heightto")==null?"":request.getParameter("heightto").trim());
        _map.put("graduationyear",request.getParameter("graduationyear")==null?"":request.getParameter("graduationyear").trim());
        _map.put("scorearea", request.getParameter("scorearea"));
        String msarrange=request.getParameter("msarrange");
        if(StringTools.trimNotEmpty(msarrange)){
            if (msarrange.equalsIgnoreCase("未安排")){
                _map.put("msarrange"," is null ");
            }else if(msarrange.equalsIgnoreCase("已安排")){
                _map.put("msarrange"," is not null ");
            }
        }
        String tjarrange=request.getParameter("tjarrange");
        if (StringTools.trimNotEmpty(tjarrange)){
            if (tjarrange.equalsIgnoreCase("未安排")){
                _map.put("tjarrange"," is null ");
            }else if(tjarrange.equalsIgnoreCase("已安排")){
                _map.put("tjarrange"," is not null ");
            }
        }
        String msresult=request.getParameter("mresult");
        if (StringTools.trimNotEmpty(msresult)){
                _map.put("msresult",msresult);

        }
        /*while (pnames.hasMoreElements()){
            String key=pnames.nextElement();
            String value= request.getParameter(key);
            System.out.println(key+":::"+value);
        }*/
        if(paramMap.size()>0){
            try {
               /* String pid=request.getParameter("pid");
                String fid=request.getParameter("fid");*/
                //String searchdata=request.getParameter("searchdata");
                ProjectInfo projectInfo=projectService.getpProjectById(hrzzUser.getPid());
                codedFileName = java.net.URLEncoder.encode(projectInfo.getPname(), "UTF-8");
                response.setHeader("content-disposition", "attachment;filename=" + codedFileName + ".xls");
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = workbook.createSheet("人员信息");
                int index=0;
                String selectColumns="";
                HSSFRow headrow = sheet.createRow(0);//创建一行
                for (String pkey : paramMap.keySet()) {
                    if (pkey.startsWith("KEY.")) {
                        HSSFCell headcel0 = headrow.createCell(index);
                        headcel0.setCellValue(new HSSFRichTextString(paramMap.get(pkey)[0]));
                        selectColumns += pkey.replace("KEY.","") + ",";
                        index++;
                    }
                }
                selectColumns=selectColumns.substring(0,selectColumns.length()-1);
                selectColumns=selectColumns.replace("p.ROWNUM","ROWNUM");
                if(StringTools.trimNotEmpty(hrzzUser.getFid())&&StringTools.trimNotEmpty(hrzzUser.getPath())){
                    hrzzUser.setFid("");
                }
                List<Object[]> userResumeList=excelExportService.queryZZUserBySearch(hrzzUser,_map,selectColumns);
                if(userResumeList.size()>0){
                    int flag=1;
                    for (Object[] obj : userResumeList) {
                        HSSFRow row = sheet.createRow(flag);//创建一行
                        for (int j = 0; j < obj.length; j++) {
                            HSSFCell cell = row.createCell(j);//创建一列
                            //cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                            cell.setCellType(CellType.STRING);
                            cell.setCellValue(new HSSFRichTextString(
                                    obj[j] == null ? "" : obj[j].toString()));
                        }
                        flag++;
                    }
                }
                fOut = response.getOutputStream();
                workbook.write(fOut);

            }catch (Exception e){
                e.printStackTrace();
            }finally {
                try {
                    fOut.flush();
                    fOut.close();
                } catch (IOException e) {
                }
            }
        }


    }


    /**
     * 跳转签到表页面
     * @param request
     * @param response
     */
    @RequestMapping("/DownExamInfo")
    public String DownSign(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
        try {
            String pid = request.getParameter("pid").trim();//招聘方案ID
            String fid = request.getParameter("fid").trim();//招聘流程ID
            String deptcode=request.getParameter("deptcode");
            List<ProjectInfoJobs> projectJobs=utilService.getProjectJobs(pid);
            model.addAttribute("jobs",projectJobs);
            model.addAttribute("pid", pid);
            model.addAttribute("fid", fid);
            model.addAttribute("deptcode", deptcode);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/ExcelDown/DownExamInfo";
    }


}
